package cn.edu.zafu.bigdata.x.sxy;

public class Course {
    // 课程属性
    private final String courseName; // 课程名称
    private final String courseNumber;//课程编号
    private final String instructor; // 讲师
    private final int credits; // 学分
    private final String[] students; // 学生数组

    // 构造方法
    public Course(String courseName,String courseNumber, String instructor, int credits, String[] students) {
        this.courseName = courseName;
        this.courseNumber = courseNumber;
        this.instructor = instructor;
        this.credits = credits;
        this.students = students;
    }

    // 打印课程信息的方法
    public void print() {
        System.out.println("Course Name: " + courseName);
        System.out.println("Course Number: " + courseNumber);
        System.out.println("Instructor: " + instructor);
        System.out.println("Credits: " + credits);
        System.out.print("Students enrolled: ");
        for (String student : students) {
            System.out.print(student + " ");
        }
        System.out.println(); // 换行
    }
    // 主方法，用于测试Course类
    public static void main(String[] args) {
        // 创建学生数组
        String[] enrolledStudents = {"Ji", "Ni", "Tai", "Mei"};

        // 创建课程实例
        Course course = new Course("Introduction to Java","0001", "Dr. Sun",
                3, enrolledStudents);

        // 打印课程信息
        course.print();
    }
}